package com.seanLab.web;

import com.seanLab.domain.Body;
import com.seanLab.domain.Image;
import com.seanLab.dto.RecommendArticleDto;
import com.seanLab.repository.ImageRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by ailly on 17-10-10.
 */
@RestController
@RequestMapping("/v1/test")
public class TestController {
    @Autowired
    private TAppProp tt;

    @Value("${location}")
    private String location;

    @Autowired
    ImageRepo imageRepo;

    @RequestMapping(path = "/testAppProperties", method = RequestMethod.GET)
    public int testAppProperties() {
        System.out.println(tt);
        System.out.println(location);

        Image i = imageRepo.findByImgID("imageID-f7bdc6c2-9d9f-4a32-8e9f-0df813749600");

        return 0;
    }

}

@ConfigurationProperties(prefix = "com.ailly.test")
@Component
class TAppProp {
    private String name;
    private String mobile;

    public TAppProp() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String toString() {
        return "Name: " + name + " Mobile: " + mobile;
    }
}


